home *** CD-ROM | disk | FTP | other *** search
- /*
- trap.c
- Functions to support testing for traps
- and testing for Gestalt features.
-
- 11-13-90 1.0d3 JRP original (for Alias XFCN)
- 11-14-90 1.0d1 JRP add helpMgrPresent
- change aliasAvailable to aliasMgrPresent
- 08-Apr-93 1.2d1 JRP correct error in Gestalt parameter,
- was causing write-to-nil.
- */
-
- #include <Types.h>
- #include <Traps.h>
- #include <OSUtils.h>
- #include <GestaltEqu.h>
-
- #include "trap.pro"
-
- short helpMgrPresent(void)
- /*
- Returns true if the Help Manager is present.
- */
- {
- long response;
- short result=false;
-
- if(gestaltAvailable())
- {
- if(Gestalt(gestaltHelpMgrAttr, &response)==noErr)
- {
- // See if the gestaltHelpMgrPresent-th bit is set.
- result = response & (1 << gestaltHelpMgrPresent);
- }
- }
- return result;
- } /* -------------------------------------------- helpMgrPresent */
-
- short aliasMgrPresent(void)
- /*
- Returns true if Alias Manager is present.
- */
- {
- long response;
- short result=false;
-
- if(gestaltAvailable())
- {
- if(Gestalt(gestaltAliasMgrAttr, &response)==noErr)
- {
- // See if the gestaltAliasMgrPresent-th bit is set.
- result = response & (1 << gestaltAliasMgrPresent);
- }
- }
- return result;
- } /* -------------------------------------------- aliasMgrPresent */
-
- short gestaltAvailable(void)
- /*
- Returns true if gestalt is available.
- From IM-VI. chap 3, page 8
- */
- {
- #define _Gestalt 0xA1AD
-
- return(trapAvailable(_Gestalt));
- } /* -------------------------------------------- gestaltAvailable */
-
- short getTrapType(theTrap)
- /*
- Returns the trap type.
- From IM-VI. chap 3, page 8
- */
- short theTrap;
- {
- #define trapMask 0x0800
-
- if(theTrap & trapMask)
- return ToolTrap;
- else
- return OSTrap;
- } /* -------------------------------------------- getTrapType */
-
- short numToolboxTraps(void)
- /*
- Returns the number of toolbox traps.
- From IM-VI. chap 3, page 8
- */
- {
- if(NGetTrapAddress(_InitGraf, ToolTrap)==
- NGetTrapAddress(0xAA6E, ToolTrap))
- return 0x200;
- else
- return 0x400;
- } /* -------------------------------------------- numToolboxTraps */
-
- short trapAvailable(theTrap)
- /*
- Returns true if the trap is available.
- From IM-VI. chap 3, page 8
- */
- short theTrap;
- {
- short tType;
-
- tType = getTrapType(theTrap);
- if(tType==ToolTrap)
- {
- theTrap = theTrap & 0x07FF;
- if(theTrap>=numToolboxTraps())
- theTrap = _Unimplemented;
- }
- return(NGetTrapAddress(theTrap, tType)!=
- NGetTrapAddress(_Unimplemented, ToolTrap));
- } /* -------------------------------------------- trapAvailable */
-
-